{
    _CP_.OPTIONS_HANDLER.set('controls', {
        [Etype.boolean]: U.F.fn.obj,
    });
}

type Toptions_CONTROLS = {
    /** true: 可重置; false: 不可重置; */
    resetable?: boolean;
    /** true: 可清空; false: 不可清空; */
    clearable?: boolean;
};

/**
 * 颜色控件注解
 * @param target 目标类型
 */
function ACcontrols(target: any) {
    if (!U.isSubClass(__CVP__, target)) { return; }

    // 处理器
    const original_options_handlers = target.prototype.options_handlers;
    target.prototype.options_handlers = function (this: __CVP__<any>) {
        const options_handlers = original_options_handlers.call(this);

        U.O.setDefaultValue(options_handlers, 'resetable', _CP_.OPTIONS_HANDLER.get('controls'));
        U.O.setDefaultValue(options_handlers, 'clearable', _CP_.OPTIONS_HANDLER.get('controls'));

        return options_handlers;
    };

    // 初始化
    const original_afterInitializer = target.prototype.afterInitializer;
    target.prototype.afterInitializer = function (this: __CVP__<any>) {
        original_afterInitializer.call(this);

        // 控制按钮
        if (this.options.resetable || this.options.clearable) {
            const plugin = this;
            const ele_controls = U.D.createElement('div').addClass(_CP_.CLASSES.CONTROLS).insertTo(this.ele);

            // 还原按钮
            if (this.options.resetable) {
                K.button({
                    icon: 'reset',
                    onclick: () => {
                        plugin.setValue(plugin.options.value);
                    }
                }).insertTo(ele_controls);
            }

            // 清除按钮
            if (this.options.clearable) {
                K.button({
                    icon: 'clear',
                    onclick: () => {
                        plugin.setValue(DEFAULT);
                    }
                }).insertTo(ele_controls);
            }
        }
    };
}
